package com.bjdd.jdy.entity;

import com.bigkoo.pickerview.model.IPickerViewData;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/12.
 */

public class ProvinceBean implements IPickerViewData{

    /**
     * provinceId : 1
     * provinceName : 福建省
     * provinceCode : 35
     * enable : true
     * cities : [{"cityId":1,"cityName":"福州市","cityCode":"3501","enable":true,"areas":[{"areaId":2,"areaName":"台江区","areaCode":"350103","enable":true},{"areaId":1,"areaName":"鼓楼区","areaCode":"350102","enable":true}]},{"cityId":2,"cityName":"厦门市","cityCode":"3502","enable":false,"areas":[{"areaId":3,"areaName":"思明区","areaCode":"350203","enable":true}]}]
     */

    private int provinceId;
    private String provinceName;
    private String provinceCode;
    private boolean enable;
    private List<CityBean> cities;

    public static ProvinceBean objectFromData(String str) {

        return new Gson().fromJson(str, ProvinceBean.class);
    }

    public static List<ProvinceBean> arrayProvinceBeanFromData(String str) {

        Type listType = new TypeToken<ArrayList<ProvinceBean>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public int getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(int provinceId) {
        this.provinceId = provinceId;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getProvinceCode() {
        return provinceCode;
    }

    public void setProvinceCode(String provinceCode) {
        this.provinceCode = provinceCode;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public List<CityBean> getCities() {
        return cities;
    }

    public void setCities(List<CityBean> cities) {
        this.cities = cities;
    }

    @Override
    public String getPickerViewText() {
        return provinceName;
    }

}
